// index.js
import {network} from "network.js"

Page({
  data: {
  },
  // 事件处理函数

  onLoad:function(options){
    var that = this;
    //电影
    wx.request({
      // url: 'https://m.douban.com/rexxar/api/v2/subject_collection/movie_showing/items?count=7',
      url:"http://39.105.38.10:8081/movie/playing?city=guangzhou",
      // data:{
      //   count:7
      // },
      success:function(res){
        var movies = res.data.data.subject;
        // console.log(movies);
        that.setData({
          movies:movies,
        })
      }
    })

    //电视剧
    // wx.request({
    //   url: 'https://m.douban.com/rexxar/api/v2/subject_collection/tv_hot/items?count=7',
    //   success:function(res){
    //     // console.log(res);
    //     var tvs = res.data.subject_collection_items;
    //     // console.log(tvs);
    //     that.setData({
    //       tvs:tvs,
    //     })
    //   }
    // })
    var tvsUrl = 'https://m.douban.com/rexxar/api/v2/subject_collection/tv_hot/items?count=7';
    network.getList({   
      success:function(tvs){
        that.setData({
          tvs:tvs
        })
      }
    },tvsUrl)

    //综艺
    // wx.request({
    //   url: 'https://m.douban.com/rexxar/api/v2/subject_collection/tv_variety_show/items?count=7',
    //   // url:"http://39.105.38.10:8081/movie/playing?city=guangzhou",
    //   // data:{
    //   //   count:7
    //   // },
    //   success:function(res){
    //     // console.log(res);
    //     var shows = res.data.subject_collection_items;
    //     // console.log(shows);
    //     that.setData({
    //       shows:shows,
    //     })
    //   }
    // })
    var showsUrl = 'https://m.douban.com/rexxar/api/v2/subject_collection/tv_variety_show/items?count=7';
    network.getList({   
      success:function(shows){
        that.setData({
          shows:shows,
        })
      }
    },showsUrl)
  }
})


